/**
 * <p>SystemName: WLBSNS</p>
 * <p>Description: </p> 
 * <p>Copyright: Copyright (c) 2013 </p> 
 * <p>Company: </p> 
 * @author Theron 
 * @date 2013年11月8日 下午10:30:37 
 * @version V1.0 
 */
package com.wlbsns.demo.dao;

import java.util.List;

import com.wlbsns.demo.entity.Demo;
import com.wlbsns.framework.base.BaseDaoImpl;
import com.wlbsns.framework.exception.SystemException;
import com.wlbsns.framework.tools.DateUtils;

/**
 * desciption: 演示dao的使用
 * 
 * @author Theron
 * @date 2013年11月8日 下午10:30:37
 */
public class DemoDaoImpl extends BaseDaoImpl {

	String tablename ="demo";
	
	@Override
	public int addObj(Object obj) throws SystemException {

		// 强转对象
		Demo demo = (Demo) obj;
		
		// 创建sql语句
		String sql = "insert into "+tablename+"(dname,dpassword,dsex,dbirthday,dmoney) values(?,?,?,?,?)";

		// 获取参数对象
		Object[] objs = new Object[] { demo.getDname(), demo.getDpassword(),
				demo.getDsex(), DateUtils.dateToSqlDate(demo.getDbirthday()),
				demo.getDmoney() };

		return super.addObj(sql, objs);
	}

	@Override
	public int updateObj(Object... objs) throws SystemException {
		
		String sql = "update "+tablename+" set dmoney=? where dname=?";
		
		return super.updateObj(sql,objs);
	}

	@Override
	public int deleteObj(Object... objs) throws SystemException {
		
		String sql = "delete from "+tablename+" where dname=?";
		return super.deleteObj(sql,objs);
	}

	@Override
	public <T> T getObjInfo(Class<T> clazz) throws SystemException {
		
		String sql = "select * from "+tablename;
		
		return super.getObjInfo(sql,clazz);
	}

	@Override
	public <T> T getObjByCondition(Class<T> clazz, Object... objs)
			throws SystemException {
		
		String sql = "select * from "+tablename+" where dname=? and dpassword=?";
		
		return super.getObjByCondition(sql,clazz, objs);
	}

	@Override
	public <T> List<T> getObjs(Class<T> clazz) throws SystemException {
		
		return super.getObjs(clazz);
	}

}
